﻿using kzjd.rycp.WebApp.App_Start;
using kzjd.rycp.WebApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApp.BLL;
using WebApp.BLL.Basic;
using WebApp.BLL.Evaluate;
using WebApp.BLL.Manage;
using WebApp.Common;
using WebApp.Models;
using WebApp.ViewModels;
using WebApp.ViewModels.Evaluate;
using WebApp.Web.Core;

namespace kzjd.rycp.WebApp.Controllers
{
    public class EvalController : Controller
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger("WebApp.Log");

        #region 测评首页
        // GET: Eval
        public ActionResult Index()
        {
            return RedirectToAction("Login", "Eval");
            //var doc = new S_documentService().SelectByDocKey("eval_readme");

            //if (doc == null)
            //{
            //    ViewBag.Content = "";
            //}
            //else
            //{
            //    ViewBag.Content = doc.Content;
            //}

            //return View();
        }

        #endregion

        #region 测评科室登录

        [HttpGet]
        public ActionResult Login()
        {
            ViewBag.CanLogin = true;
            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();
            if (eval.Status != (int)enmEvalStatus.进行中)
            {
                ViewBag.CanLogin = false;
                ViewBag.ErrorMessage = "当前年度测评已关闭！";
            }
            else if (eval.EvaluateStart.HasValue && DateTime.Now.Date < eval.EvaluateStart.Value.Date)
            {
                ViewBag.CanLogin = false;
                ViewBag.ErrorMessage = "本年度测评尚未开始，不能登录！";
            }
            else if (eval.EvaluateEnd.HasValue && DateTime.Now.Date > eval.EvaluateEnd.Value.Date)
            {
                ViewBag.CanLogin = false;
                ViewBag.ErrorMessage = "本年度测评已结束，不能登录！";
            }

            //科室下拉框数据
            var deptList = new T_evaluate_deptService().ListByEvalId(eval.Id);
            var deptIds = deptList.Select(p => p.Eval_dept_id).ToList();
            ViewBag.DeptSelectList = new S_departmentService().GetSelectList(deptIds);

            //各科室测评人数
            ViewBag.DeptMembers = Newtonsoft.Json.JsonConvert.SerializeObject(deptList.Select(p => new { p.Eval_dept_id, p.Requireusers }));

            return View(new EvalLoginModel());
        }

        [HttpPost]
        public ActionResult Login(EvalLoginModel model)
        {
            ViewBag.CanLogin = true;
            ViewBag.DeptMembers = "[]";

            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();

            var dept = new T_evaluate_deptService().SelectByEvalIdAndDeptId(eval.Id, Utils.NvInt(model.Dept_id));

            if (dept == null || !dept.Password.Equals(model.Password))
            {
                //科室下拉框数据
                ViewBag.DeptSelectList = new S_departmentService().GetSelectList(enmDeptType.Worker.ToString());

                //科室下拉框数据
                var deptList = new T_evaluate_deptService().ListByEvalId(eval.Id);
                var deptIds = deptList.Select(p => p.Eval_dept_id).ToList();
                ViewBag.DeptSelectList = new S_departmentService().GetSelectList(deptIds);

                //各科室测评人数
                ViewBag.DeptMembers = Newtonsoft.Json.JsonConvert.SerializeObject(deptList.Select(p => new { p.Eval_dept_id, p.Requireusers }));

                model.LoginResult = -1;
                model.ErrorMessage = "科室密码不正确！";
                return View(model);
            }

            var sessionModel = new EvalMemberSessionModel();
            sessionModel.Dept_id = dept.Eval_dept_id;
            sessionModel.Deptname = dept.Eval_deptname;
            sessionModel.Member = model.Member;
            EvalMemberSession.Member = sessionModel;

            //登录成功
            var backurl = Request.QueryString["backurl"];
            if (!string.IsNullOrEmpty(model.ActionUrl))
            {
                return Redirect(model.ActionUrl);
            }
            else if (string.IsNullOrEmpty(backurl))
            {
                return Redirect(Url.Action("Index", "Eval"));
            }
            else
            {
                return Redirect(backurl);
            }
        }

        #endregion

        #region 退出登录

        public ActionResult Logout()
        {
            EvalMemberSession.Member = null;

            return RedirectToAction("Index", "Eval");
        }

        #endregion

        #region 机关科室测评

        [EvalAuthorizeFilter]
        public ActionResult OfficeDept()
        {
            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();
            if (eval.Status == (int)enmEvalStatus.已结束)
            {
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
            }
            ViewBag.EvalId = eval.Id;

            //测评结果文字
            var dictservice = new S_dictService();
            ViewBag.ResultName_1 = dictservice.GetName("OfficeResult", "10");
            ViewBag.ResultName_2 = dictservice.GetName("OfficeResult", "20");
            ViewBag.ResultName_3 = dictservice.GetName("OfficeResult", "30");

            //当前测评人员
            var member = EvalMemberSession.Member;

            //科室列表
            var deptList = new S_departmentService().ListByDeptType(enmDeptType.Manager.ToString());
            //当前已填写的结果
            var evalResult = new T_evaluate_officeresultService().InitResult(eval.Id, member.Dept_id, member.Member, deptList);

            var list = new List<OfficeDetpResultModel>();
            foreach (var item in deptList)
            {
                var model = new OfficeDetpResultModel();
                model.Dept_id = item.Id;
                model.Deptname = item.Deptname;

                var result = evalResult.FirstOrDefault(p => p.Dest_dept_id == item.Id);
                if (result != null)
                {
                    model.Result_1 = result.Result_1;
                    model.Result_2 = result.Result_2;
                    model.Result_3 = result.Result_3;
                    model.Result_4 = result.Result_4;
                    model.Result_5 = result.Result_5;
                    model.Result_6 = result.Result_6;
                }

                list.Add(model);
            }

            if (evalResult.Count > 0 && evalResult.First().Status == (int)enmEvalResultStatus.已提交)
            {
                //测评结果已提交，不能修改
                ViewBag.CanEdit = false;
            }
            else
            {
                ViewBag.CanEdit = true;
            }

            return View(list);
        }

        #endregion

        #region 机关管理人员测评

        [EvalAuthorizeFilter]
        public ActionResult OfficeMember()
        {
            var memberservice = new S_dept_memberService();

            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();
            if (eval.Status == (int)enmEvalStatus.已结束)
            {
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
            }


            //当前测评人员
            var member = EvalMemberSession.Member;

            //科室列表
            var deptList = new S_departmentService().ListByDeptType(enmDeptType.Manager.ToString());

            var list = new List<OfficeDeptModel>();
            foreach (var item in deptList)
            {
                var model = new OfficeDeptModel();
                model.Dept_id = item.Id;
                model.Deptname = item.Deptname;

                //科室人数
                model.MemberCount = memberservice.CountByDeptid(item.Id);

                //测评状态
                var evalResult = new T_evaluate_officememberresultService().ListByMember(eval.Id, member.Dept_id, member.Member, item.Id);
                if (evalResult.Count > 0 && evalResult.First().Status == 1)
                {
                    model.Status = 1;
                }
                list.Add(model);
            }

            return View(list);
        }

        [EvalAuthorizeFilter]
        public ActionResult OfficeMemberDetail(string id)
        {
            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();
            if (eval.Status == (int)enmEvalStatus.已结束)
            {
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
            }
            ViewBag.EvalId = eval.Id;

            //测评结果文字
            var dictservice = new S_dictService();
            ViewBag.ResultName_1 = dictservice.GetName("OfficeMemberResult", "10");
            ViewBag.ResultName_2 = dictservice.GetName("OfficeMemberResult", "20");
            ViewBag.ResultName_3 = dictservice.GetName("OfficeMemberResult", "30");

            //当前测评人员
            var member = EvalMemberSession.Member;

            //当前科室
            var dept = new S_departmentService().Find(Utils.NvInt(id));
            ViewBag.DeptId = dept.Id;
            ViewBag.DeptName = dept.Deptname;
            //机关科室管理人员
            var memberList = new S_dept_memberService().ListByDeptid(dept.Id);
            //当前已填写的结果
            var evalResult = new T_evaluate_officememberresultService().InitResult(eval.Id, member.Dept_id, member.Member, dept, memberList);

            var list = new List<OfficeMemberResultModel>();
            foreach (var item in memberList)
            {
                var model = new OfficeMemberResultModel();
                model.Dept_id = dept.Id;
                model.Deptname = dept.Deptname;
                model.Member_id = item.Id;
                model.Membername = item.Name;
                model.Job = item.Job;
                model.Avatarurl = item.Avatorurl;
                model.Remark = item.Remark;

                var result = evalResult.FirstOrDefault(p => p.Dest_member_id == item.Id);
                if (result != null)
                {
                    model.Noresult = result.Noresult;
                    model.Result_1 = result.Result_1;
                    model.Result_2 = result.Result_2;
                    model.Result_3 = result.Result_3;
                    model.Result_4 = result.Result_4;
                    model.Result_5 = result.Result_5;
                }

                list.Add(model);
            }

            if (evalResult.Count > 0 && evalResult.First().Status == (int)enmEvalResultStatus.已提交)
            {
                //测评结果已提交，不能修改
                ViewBag.CanEdit = false;
            }
            else
            {
                ViewBag.CanEdit = true;
            }

            return View(list);
        }

        #endregion

        #region 本车间管理人员测评

        [EvalAuthorizeFilter]
        public ActionResult WorkerMember()
        {
            //测评主记录
            var eval = new T_evaluateService().GetCurrentEval();
            if (eval.Status == (int)enmEvalStatus.已结束)
            {
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
            }
            ViewBag.EvalId = eval.Id;

            //测评结果文字
            var dictservice = new S_dictService();
            ViewBag.ResultName_1 = dictservice.GetName("WorkerMemberResult", "10");
            ViewBag.ResultName_2 = dictservice.GetName("WorkerMemberResult", "20");
            ViewBag.ResultName_3 = dictservice.GetName("WorkerMemberResult", "30");
            ViewBag.ResultName_4 = dictservice.GetName("WorkerMemberResult", "40");

            //当前测评人员
            var member = EvalMemberSession.Member;

            //当前被测评科室
            var dept = new S_departmentService().Find(member.Dept_id);
            ViewBag.DeptId = dept.Id;
            ViewBag.DeptName = dept.Deptname;
            //车间管理人员
            var memberList = new S_dept_memberService().ListByDeptid(dept.Id);
            //当前已填写的结果
            var evalResult = new T_evaluate_workermemberresultService().InitResult(eval.Id, member.Dept_id, member.Member, dept, memberList);

            var list = new List<WorkerMemberResultModel>();
            foreach (var item in memberList)
            {
                var model = new WorkerMemberResultModel();
                model.Dept_id = dept.Id;
                model.Deptname = dept.Deptname;
                model.Member_id = item.Id;
                model.Membername = item.Name;
                model.Job = item.Job;
                model.Avatarurl = item.Avatorurl;
                model.Remark = item.Remark;

                var result = evalResult.FirstOrDefault(p => p.Dest_member_id == item.Id);
                if (result != null)
                {
                    model.Result_1 = result.Result_1;
                    model.Result_2 = result.Result_2;
                    model.Result_3 = result.Result_3;
                    model.Result_4 = result.Result_4;
                    model.Result_5 = result.Result_5;
                }

                list.Add(model);
            }

            if (evalResult.Count > 0 && evalResult.First().Status == (int)enmEvalResultStatus.已提交)
            {
                //测评结果已提交，不能修改
                ViewBag.CanEdit = false;
            }
            else
            {
                ViewBag.CanEdit = true;
            }

            return View(list);
        }

        #endregion

        #region 图片文件流

        public ActionResult AvatarImage()
        {
            string tempfile = Utils.NvStr(Request["path"]);
            string uploadroot = new S_environmentService().GetValue("upload.rootpath");
            string filepath = uploadroot + tempfile.Replace("/", "\\");
            if (!System.IO.File.Exists(filepath))
            {
                filepath = Request.MapPath("/content/images/avatar.png");
                //return HttpNotFound();
            }

            return File(filepath, "image/jpeg");
        }

        #endregion

        #region 保存机关科室测评单项结果

        /// <summary>
        /// 保存机关科室测评单项结果
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="fieldname"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SaveOfficeItemResult(int evalId, int deptId, string fieldname, string result)
        {
            try
            {
                var resultservice = new T_evaluate_officeresultService();

                var member = EvalMemberSession.Member;

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                //被测评科室
                var dept = new S_departmentService().Find(deptId);

                var resultModel = resultservice.SelectByKey(eval.Id, member.Dept_id, member.Member, deptId);
                if (resultModel == null)
                {
                    resultModel = new T_evaluate_officeresult();
                    resultModel.Eval_id = eval.Id;
                    resultModel.Eval_dept_id = member.Dept_id;
                    resultModel.Eval_member = member.Member;
                    resultModel.Dest_dept_id = deptId;
                    resultModel.Dest_deptname = dept.Deptname;
                    resultModel.Status = (int)enmEvalResultStatus.未提交;
                }

                if (fieldname == "Result_1")
                {
                    resultModel.Result_1 = result;
                }
                else if (fieldname == "Result_2")
                {
                    resultModel.Result_2 = result;
                }
                else if (fieldname == "Result_3")
                {
                    resultModel.Result_3 = result;
                }
                else if (fieldname == "Result_4")
                {
                    resultModel.Result_4 = result;
                }
                else if (fieldname == "Result_5")
                {
                    resultModel.Result_5 = result;
                }
                else if (fieldname == "Result_6")
                {
                    resultModel.Result_6 = result;
                }

                //保存结果
                resultservice.Save(resultModel);

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

        #region 提交机关科室测评结果

        /// <summary>
        /// 提交机关科室测评结果
        /// </summary>
        /// <param name="evalId"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SubmitOfficeItemResult(int evalId)
        {
            try
            {
                var resultservice = new T_evaluate_officeresultService();

                var member = EvalMemberSession.Member;

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                var resultList = resultservice.ListByMember(eval.Id, member.Dept_id, member.Member);

                if (resultList.Where(p => string.IsNullOrEmpty(p.Result_1)).Any()
                    || resultList.Where(p => string.IsNullOrEmpty(p.Result_2)).Any()
                    || resultList.Where(p => string.IsNullOrEmpty(p.Result_3)).Any()
                    || resultList.Where(p => string.IsNullOrEmpty(p.Result_4)).Any()
                    || resultList.Where(p => string.IsNullOrEmpty(p.Result_5)).Any()
                    || resultList.Where(p => string.IsNullOrEmpty(p.Result_6)).Any())
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "所有科室必须填写测评结果！"));
                }

                //提交结果
                foreach (var item in resultList)
                {
                    item.Status = (int)enmEvalResultStatus.已提交;
                    resultservice.Update(item);
                }

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

        #region 保存机关科室管理人员测评单项结果

        /// <summary>
        /// 保存机关科室管理人员测评单项结果
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="fieldname"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SaveOfficeMemberItemResult(int evalId, int deptId, int memberId, string fieldname, string result)
        {
            try
            {
                var resultservice = new T_evaluate_officememberresultService();

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                //被测评科室
                var dept = new S_departmentService().Find(deptId);
                //被测评人
                var member = new S_dept_memberService().Find(memberId);

                var resultModel = resultservice.SelectByKey(eval.Id, EvalMemberSession.Member.Dept_id, EvalMemberSession.Member.Member, memberId);
                if (resultModel == null)
                {
                    resultModel = new T_evaluate_officememberresult();
                    resultModel.Eval_id = eval.Id;
                    resultModel.Eval_dept_id = EvalMemberSession.Member.Dept_id;
                    resultModel.Eval_member = EvalMemberSession.Member.Member;
                    resultModel.Dest_dept_id = dept.Id;
                    resultModel.Dest_deptname = dept.Deptname;
                    resultModel.Dest_member_id = member.Id;
                    resultModel.Dest_membername = member.Name;
                    resultModel.Status = (int)enmEvalResultStatus.未提交;
                }

                if (fieldname == "noresult")
                {
                    resultModel.Noresult = Utils.NvInt(result);
                    if (resultModel.Noresult == 1)
                    {
                        resultModel.Result_1 = "";
                        resultModel.Result_2 = "";
                        resultModel.Result_3 = "";
                        resultModel.Result_4 = "";
                        resultModel.Result_5 = "";
                    }
                }
                else if (fieldname == "Result_1")
                {
                    resultModel.Result_1 = result;
                }
                else if (fieldname == "Result_2")
                {
                    resultModel.Result_2 = result;
                }
                else if (fieldname == "Result_3")
                {
                    resultModel.Result_3 = result;
                }
                else if (fieldname == "Result_4")
                {
                    resultModel.Result_4 = result;
                }
                else if (fieldname == "Result_5")
                {
                    resultModel.Result_5 = result;
                }

                //保存结果
                resultservice.Save(resultModel);

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

        #region 提交机关科室管理人员测评结果

        /// <summary>
        /// 提交机关科室测评结果
        /// </summary>
        /// <param name="evalId"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SubmitOfficeMemberItemResult(int evalId, int deptId)
        {
            try
            {
                var resultservice = new T_evaluate_officememberresultService();

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                var resultList = resultservice.ListByMember(eval.Id, EvalMemberSession.Member.Dept_id, EvalMemberSession.Member.Member, deptId);

                foreach (var item in resultList)
                {
                    if (item.Noresult == 1)
                    {
                        ;
                    }
                    else if (string.IsNullOrEmpty(item.Result_1)
                       || string.IsNullOrEmpty(item.Result_2)
                       || string.IsNullOrEmpty(item.Result_3)
                       || string.IsNullOrEmpty(item.Result_4)
                       || string.IsNullOrEmpty(item.Result_5))
                    {
                        return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "所有人员必须填写测评结果！"));
                    }
                }

                //提交结果
                foreach (var item in resultList)
                {
                    item.Status = (int)enmEvalResultStatus.已提交;
                    resultservice.Update(item);
                }

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

        #region 保存车间管理人员测评单项结果

        /// <summary>
        /// 保存车间管理人员测评单项结果
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="fieldname"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SaveWorkerMemberItemResult(int evalId, int deptId, int memberId, string fieldname, string result)
        {
            try
            {
                var resultservice = new T_evaluate_workermemberresultService();

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                //被测评科室
                var dept = new S_departmentService().Find(deptId);
                //被测评人
                var member = new S_dept_memberService().Find(memberId);

                var resultModel = resultservice.SelectByKey(eval.Id, EvalMemberSession.Member.Dept_id, EvalMemberSession.Member.Member, memberId);
                if (resultModel == null)
                {
                    resultModel = new T_evaluate_workermemberresult();
                    resultModel.Eval_id = eval.Id;
                    resultModel.Eval_dept_id = EvalMemberSession.Member.Dept_id;
                    resultModel.Eval_member = EvalMemberSession.Member.Member;
                    resultModel.Dest_dept_id = dept.Id;
                    resultModel.Dest_deptname = dept.Deptname;
                    resultModel.Dest_member_id = member.Id;
                    resultModel.Dest_membername = member.Name;
                    resultModel.Status = (int)enmEvalResultStatus.未提交;
                }

                if (fieldname == "Result_1")
                {
                    resultModel.Result_1 = result;
                }
                else if (fieldname == "Result_2")
                {
                    resultModel.Result_2 = result;
                }
                else if (fieldname == "Result_3")
                {
                    resultModel.Result_3 = result;
                }
                else if (fieldname == "Result_4")
                {
                    resultModel.Result_4 = result;
                }
                else if (fieldname == "Result_5")
                {
                    resultModel.Result_5 = result;
                }

                //保存结果
                resultservice.Save(resultModel);

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

        #region 提交车间管理人员测评结果

        /// <summary>
        /// 提交车间管理人员测评结果
        /// </summary>
        /// <param name="evalId"></param>
        /// <returns></returns>
        [EvalAuthorizeFilter(true)]
        public JsonResult SubmitWorkerMemberItemResult(int evalId, int deptId)
        {
            try
            {
                var resultservice = new T_evaluate_workermemberresultService();

                var eval = new T_evaluateService().Find(evalId);
                if (eval.Status == (int)enmEvalStatus.已结束)
                {
                    return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "本年度测评已结束，不能提交！"));
                }

                var resultList = resultservice.ListByMember(eval.Id, EvalMemberSession.Member.Dept_id, EvalMemberSession.Member.Member, deptId);

                foreach (var item in resultList)
                {
                    if (string.IsNullOrEmpty(item.Result_1)
                       || string.IsNullOrEmpty(item.Result_2)
                       || string.IsNullOrEmpty(item.Result_3)
                       || string.IsNullOrEmpty(item.Result_4)
                       || string.IsNullOrEmpty(item.Result_5))
                    {
                        return Json(new AjaxResult(AjaxResult.RESULT_ERROR, "所有人员必须填写测评结果！"));
                    }
                }

                //提交结果
                foreach (var item in resultList)
                {
                    item.Status = (int)enmEvalResultStatus.已提交;
                    resultservice.Update(item);
                }

                return Json(new AjaxResult(AjaxResult.RESULT_OK, ""));
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new AjaxResult(AjaxResult.RESULT_ERROR, ex.Message));
            }
        }

        #endregion

    }
}